/*
*
SalesInvoiceReportController,SalesInvoiceMonthDetailHandler
*/
@isTest
private class SalesInvoiceReportControllerTest {
    static testMethod void testMethod1() {

    	  Id ldcProfile = [Select Id From Profile Where Name ='销售部直销销售员' ].Id;
          Id ldcProfile2 = [Select Id From Profile Where Name ='销售管理部助理' ].Id;

    	 User u1 = new User( Alias = 'samLdc1', 
                         Email = 'ldc@test.com.maike',
                         Emailencodingkey = 'UTF-8', 
                         Lastname = '用户1', 
                         Languagelocalekey = 'en_US',
                         Localesidkey = 'en_US', 
                         Profileid = ldcProfile, 
                         Country = 'United States',
                         IsActive = true,
                         SubCompany__c='四川省迈克实业有限公司',
                         UserDepartment__c='销售中心销售管理部(管理办)',
                         Timezonesidkey = 'America/Los_Angeles', 
                         EmployeeNumber = '123451',
                         Province__c = '四川省',
                         CompanyName='Y-MKSY',
                         FederationIdentifier='123451',
                         Username = 'Matldc1@test.com.maike',
                         ResponseCode__c = 'TTTT' );
    	 insert u1;
        User u2 = new User( Alias = 'samLdc2', 
                         Email = 'ldc@test.com.maike2',
                         Emailencodingkey = 'UTF-8', 
                         Lastname = '用户1', 
                         Languagelocalekey = 'en_US',
                         Localesidkey = 'en_US', 
                         Profileid = ldcProfile2, 
                         Country = 'United States',
                         IsActive = true,
                         SubCompany__c='四川省迈克实业有限公司',
                         UserDepartment__c='销售中心销售管理部(管理办)',
                         Timezonesidkey = 'America/Los_Angeles', 
                         EmployeeNumber = '123452',
                         Province__c = '四川省',
                         CompanyName='Y-MKSY',
                         FederationIdentifier='123452',
                         Username = 'Matldc1@test.com.maike2',
                         ResponseCode__c = 'TTTT' );
        insert u2;


        Account acc = TestUtils.createAccount();
        acc.NCICCode__c = 'xxxxdddd';
        acc.Level__c = '一级医院';
        insert acc;
        
        ProductStructure__c ps = new ProductStructure__c();
        ps.Classify3__c = '试剂';
        insert ps;
        Product__c p1 = TestUtils.createProduct();
        p1.Category0__c = '试剂';
        p1.ProductStructure__c = ps.Id;
        p1.PriceCompany__c = 'MKSY';
        p1.NCCode__c = '000001';
        p1.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('NCProduct', 'Product__c');
        
        Product__c p2 = TestUtils.createProduct();
        p2.Category0__c = '试剂';
        p2.ProductStructure__c = ps.Id;
        p2.PriceCompany__c = 'MKSY';
        p2.NCCode__c = '000002';
        p2.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('NCProduct', 'Product__c');
        insert new Product__c[] {p1, p2};

        SalesInvoiceMonthDetail__c sm1 = new SalesInvoiceMonthDetail__c();
            sm1.Nccode__c = '000001';
            sm1.AccountPK__c  = 'xxxxdddd';
            sm1.Only__c = 'xxxxx0003';
            insert sm1 ;

            SalesInvoiceReportController sr1 = new SalesInvoiceReportController();
            sr1.init();

            sr1.setError('ss');

        System.runAs(u1){
        	SalesInvoiceMonthDetail__c sm = new SalesInvoiceMonthDetail__c();
	    	sm.Nccode__c = '000001';
	    	sm.AccountPK__c  = 'xxxxdddd';
	    	sm.Only__c = 'xxxxx0001';
	    	insert sm ;

	    	SalesInvoiceReportController sr = new SalesInvoiceReportController();
	    	sr.init();

	    	sr.setError('ss');
        }
        System.runAs(u2){
            SalesInvoiceMonthDetail__c sm = new SalesInvoiceMonthDetail__c();
            sm.Nccode__c = '000001';
            sm.AccountPK__c  = 'xxxxdddd';
            sm.Only__c = 'xxxxx0002';
            insert sm ;

            SalesInvoiceReportController sr = new SalesInvoiceReportController();
            sr.init();

            sr.setError('ss');
        }
    	


    }
}